package org.dragonnova.meetingserver.core.message;

/**
 * Created by hucn on 2016/6/2.
 * Description:
 */
public class MessageBuilder extends Builder {

    private Message mMessage;

    public MessageBuilder(Message message) {
        mMessage = message;
    }

    @Override
    public Builder setAction(byte[] action) {
        mMessage.setAction(action);
        return this;
    }

    @Override
    public Builder setData(byte[] bytes) {
        mMessage.setPacketData(bytes);
        return this;
    }

    @Override
    public Builder setDataLength(int length) {
        mMessage.setPacketDataLength(length);
        return this;
    }

    @Override
    public Message create() {
        return mMessage;
    }

    @Override
    public byte[] encode() {
        return mMessage.encode();
    }

    @Override
    public Message decode(byte[] bytes) {
        return mMessage.decode(bytes);
    }

    @Override
    public Builder setEmpty() {
        mMessage.setPacketData(new byte[0]);
        mMessage.setPacketDataLength(0);
        return this;
    }
}
